package com.yaolifei.flower.core;

import java.util.ArrayList;
import java.util.List;

import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Table;

@Table("t_sys_model_column")
public class ModelColumn implements Comparable<ModelColumn> {

	public static List<ModelColumn> SYSTEM_COLUMN = createSystemColumn();

	private static List<ModelColumn> createSystemColumn() {
		List<ModelColumn> cs = new ArrayList<ModelColumn>();
		ModelColumn c = new ModelColumn();
		c.setColumnName("全球唯一码");
		c.setPhysicalName("uuid");
		c.setColumnType(ModelColumnType.VARCHAR);
		c.setColumnLength(36);
		c.setNullable(false);
		c.setDispOrder(-1);
		cs.add(c);
		return cs;
	}

	@Id
	private int columnId;
	private int modelId;
	private boolean autoIncrease;
	private String columnName;
	private String physicalName;
	private int columnType;
	private int columnLength;
	private int selectRangeType;
	private String selectRange;
	private boolean nullable;
	private String formatter;
	private String validator;
	private int dispOrder;
	private boolean created;
	private String defaultValue;

	public int getColumnId() {
		return columnId;
	}

	public void setColumnId(int columnId) {
		this.columnId = columnId;
	}

	public int getModelId() {
		return modelId;
	}

	public void setModelId(int modelId) {
		this.modelId = modelId;
	}

	public boolean isAutoIncrease() {
		return autoIncrease;
	}

	public void setAutoIncrease(boolean autoIncrease) {
		this.autoIncrease = autoIncrease;
	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public String getPhysicalName() {
		return physicalName;
	}

	public void setPhysicalName(String physicalName) {
		this.physicalName = physicalName;
	}

	public ModelColumnType getColumnType() {
		return ModelColumnType.valueOf(columnType);
	}

	public void setColumnType(ModelColumnType columnType) {
		this.columnType = columnType.getValue();
	}

	public int getColumnLength() {
		return columnLength;
	}

	public void setColumnLength(int columnLength) {
		this.columnLength = columnLength;
	}

	public int getSelectRangeType() {
		return selectRangeType;
	}

	public void setSelectRangeType(int selectRangeType) {
		this.selectRangeType = selectRangeType;
	}

	public String getSelectRange() {
		return selectRange;
	}

	public void setSelectRange(String selectRange) {
		this.selectRange = selectRange;
	}

	public boolean isNullable() {
		return nullable;
	}

	public void setNullable(boolean nullable) {
		this.nullable = nullable;
	}

	public String getFormatter() {
		return formatter;
	}

	public void setFormatter(String formatter) {
		this.formatter = formatter;
	}

	public String getValidator() {
		return validator;
	}

	public void setValidator(String validator) {
		this.validator = validator;
	}

	public int getDispOrder() {
		return dispOrder;
	}

	public void setDispOrder(int dispOrder) {
		this.dispOrder = dispOrder;
	}

	public boolean isCreated() {
		return created;
	}

	public void setCreated(boolean created) {
		this.created = created;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	@Override
	public int compareTo(ModelColumn o) {
		return this.dispOrder - o.dispOrder;
	}

	@Override
	public String toString() {
		return this.columnName + ":" + this.physicalName;
	}

}
